<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>版本管理</title>
<!-- 导入jquery核心类库 -->
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script>
<!-- 导入easyui类库 -->
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/js/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/js/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/js/easyui/ext/portal.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath }/css/default.css">	
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/easyui/ext/jquery.portal.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/easyui/ext/jquery.cookie.js"></script>
<script
	src="${pageContext.request.contextPath }/js/easyui/locale/easyui-lang-zh_CN.js"
	type="text/javascript"></script>

<script type="text/javascript">



	function doAdd(){
	
		$('#outputWindow').form('clear');
		$('#outputWindow *').trigger('blur');// 离焦
		$('#outputWindow').window("open").window('setTitle', '入库');
	}
	
	function getQueryParams(queryParams) {  
		var searchcontent = $('#searchcontent').val();
	     queryParams.cVProposer = searchcontent;  
	     return queryParams;  
	   
	 }  
	
	 //增加查询参数，重新加载表格  
    function reloadgrid() {  
  
        //查询参数直接添加在queryParams中      
        var queryParams = $('#grid').datagrid('options').queryParams;  
        getQueryParams(queryParams);  
        $('#grid').datagrid('options').queryParams = queryParams;  
        $("#grid").datagrid('load');  
    }  
	 
	function doSearch(){
		reloadgrid();
	}
	
	function doEdit(){
		var rowData = $('#grid').datagrid('getSelected');  
        
        if (rowData == null) {  
            $.messager.alert("提示", "请选择要修改的行！", "info");  
        } else{
	        $("input[name='sId']").val(rowData.sId);
			$("input[name='sName']").val(rowData.sName);
			$("input[name='sEmail']").val(rowData.sEmail);
			$("input[name='sPhone']").val(rowData.sPhone);
			$('#sSex').combobox('setValue', rowData.sSex);
			$('#sStatus').combobox('setValue', rowData.sStatus);
	 		$('#dept').combobox('select', rowData.sDeptId);

			// 弹出窗口
			  
			$("#addStandardWindow").window('open').window('setTitle', '修改员工');
        } 
	}

	// 定义列
	var columns = [ [ {
		field : 'cVDoneTime',
		title : '改版时间',
		width : 120,	
		/*align : 'center'*/
		formatter:formatterDate
	}, {
		field : 'cVProposerName',
		title : '申请人',
		width : 80,	
		/*align : 'center'*/
	}, {
		field : 'cVType',
		title : '改版原因',
		width : 60,	
		formatter:formatterCVType
		/*align : 'center'*/
	}, {
		field : 'cVBuyerName',
		title : '客户名称',
		width : 160,	
		
		/*align : 'center'*/
	}, {
		field : 'cVNumber',
		title : '改版数量',
		width : 60,
		/*align : 'center'*/
	}, {
		field : 'cVStorekeeperName',
		title : '经手人',
		width : 120,
		/*align : 'center'*/
	},{
		field : 'cVSNS',
		title : 'E尺SN',
		width : 260,
		/*align : 'center'*/
	}, {
		field : 'cVIsDone',
		title : '是否办理',
		width : 80,
		/*align : 'center'*/
		formatter:formateroBIsDone
	} ] ];
	


	function formatterCVType(value){
		if(value==0){
			return '自用改版';
		}else if(value==1){
			return '客户改版';
		}
	}
	function formatterDate(value,row,index){
		if(value==''||null==value){
			return '';
		}
		var now = new Date(parseInt(value) * 1000);  
		var year=now.getYear()+1900; 
		var month=now.getMonth()+1; 
		var date=now.getDate(); 
		var hour=now.getHours(); 
		var minute=now.getMinutes();
		minute= (minute > 9) ? minute=minute : minute='0'+minute;
		//var second=now.getSeconds(); 
		return year+"-"+month+"-"+date+" "+hour+":"+minute; 
	}
	
	 function formateroBIsDone(value,row,index){
		if(value==false){
			return "否";
		}else{
			return "是";
		}
	} 
	


	


	$(function(){
		/* 		$('#add').click(doAdd);
		$('#edit').click(doEdit);
 */		$('#search').click(doSearch);
	});
	$(function(){
		// 先将body隐藏，再显示，不会出现页面刷新效果
		$("body").css({visibility:"visible"});
		
		// 收派标准数据表格
		$('#grid').datagrid( {
			iconCls : 'icon-forward',
			fit : true,
			border : false,
			rownumbers : true,
			singleSelect:true,
			striped : true,
			toolbar : '#tb',
			url : "${pageContext.request.contextPath}/page.changeVersionList.ashx",
			idField : 'sId',
			columns : columns,
			pageList: [20,30,50,100],
			pagination:true,
			view:myview,
			emptyMsg:"<font size=6>暂无记录</font>"
			
		});
		
		//初始化员工窗口
		$('#outputWindow').window({
            title: '入库',
            width: 400,
            modal: true,
            shadow: true,
            closed: true,
            height: 400,
            resizable:false
            
        });
		
		
		
		//提交表单
		$('#save').click(function(){
				// 校验
				if($('#sform').form('validate')){
					// 1 、获得form 数据
					var params = $('#sform').serialize();
					// 2、将数据发送给服务器 
					$.post("${pageContext.request.contextPath}/page.saveOrderBack.ashx", params , function(data){
						if(data == "success"){
							// 成功
							$.messager.alert('消息','操作成功 ','info');
							// 关闭窗口
							$('#outputWindow').window('close');
							// 清除表单数据
							$('#outputWindow').form('clear');
							$('#outputWindow *').trigger('blur');// 离焦
							
							// 刷新表格数据 
							$('#grid').datagrid('reload');
						}else{
							$.messager.alert('消息','操作失败 ','info');
						}
							
					});
				}
				
			});	
		
		
	});
	
	
	
	var myview = $.extend({},$.fn.datagrid.defaults.view,{
		onAfterRender:function(target){
			$.fn.datagrid.defaults.view.onAfterRender.call(this,target);
			var opts = $(target).datagrid('options');
			var vc = $(target).datagrid('getPanel').children('div.datagrid-view');
			vc.children('div.datagrid-empty').remove();
			if (!$(target).datagrid('getRows').length){
				var d = $('<div class="datagrid-empty"></div>').html(opts.emptyMsg || 'no records').appendTo(vc);
				d.css({
					position:'absolute',
					left:0,
					top:50,
					width:'100%',
					textAlign:'center'
				});
			}
		}
	});


	
	
		
</script>	
</head>
<body class="easyui-layout" >
	<div region="center">
	
		<table id="grid">
		
		</table>
	</div>
	
	<%-- <div class="easyui-window"  id="outputWindow" collapsible="false" minimizable="false" maximizable="false" style="top:50px;left:200px">
		<div region="north" style="height:31px;overflow:hidden;" split="false" border="false" >
			<div class="datagrid-toolbar">
				<a id="save" icon="icon-save" href="#" class="easyui-linkbutton" plain="true" >保存</a>
			</div>
		</div>
		<div region="center" style="overflow:auto;padding:5px;" border="false">
			<form id="sform">
				<table class="table-edit" width="80%" align="center">
					<tr class="title">
						<td colspan="2">入库</td>
					</tr>
					
					
					<tr>
						<td>申请人</td>
<!-- 						<td><input name="oBReceiver" type="text" class="easyui-validatebox"  required="true" missingMessage="不能为空" /></td>
 -->						<td>
						<input class="easyui-combobox"   editable="false",
									required="true"
									name="oBProposer"
									id="kuguan"
									data-options="
											url:'${pageContext.request.contextPath}/page.kuguanListAll.ashx',
											method:'get',
											valueField:'sName',
											textField:'sName',
											panelHeight:'300'
						"></td>
					
					</tr>
					<tr>
						<td>经手人</td>
						<td>
						<input class="easyui-combobox"   editable="false",
									required="true"
									name="oBKuGuanName"
									id="kuguan"
									data-options="
											url:'${pageContext.request.contextPath}/page.kuguanListAll.ashx',
											method:'get',
											valueField:'sName',
											textField:'sName',
											panelHeight:'300'
						"></td>
					</tr>
					
					<tr>
						<td>入库数量</td>
						<td><input name="oBPNumber" type="text" class="easyui-validatebox"  required="true"  /></td>
					</tr>
					
					<tr>
						<td>备注</td>
						<td><input name="oBReMark" type="text"   /></td>
					</tr>
					
				
					</table>
			</form>
		</div>
	</div>
 --%>	

	
		<div id="tb" style="padding:5px;height:auto">
		<div style="margin-bottom:5px">
<!--			<a href="#" id="add" class="easyui-linkbutton" iconCls="icon-add" plain="true" >增加</a>
 			<a href="#" id="edit" class="easyui-linkbutton" iconCls="icon-edit" plain="true">编辑</a>
 -->			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;申请人: <input id="searchcontent" class="easyui-textbox" style="width:80px">
			<a href="#"  id="search" class="easyui-linkbutton" iconCls="icon-search">搜索</a>
		
		</div>
	</div>
	
	

	
	
	
</body>
</html>